package com.pingbu.tijian.hospital.backapi.api;

import com.github.pagehelper.PageInfo;
import com.pingbu.common.bean.ResultBean;
import com.pingbu.tijian.hospital.backapi.bean.entity.Student;
import com.pingbu.tijian.hospital.backapi.bean.entity.StudentGroup;
import com.pingbu.tijian.hospital.backapi.service.StudentGroupService;
import com.pingbu.tijian.hospital.backapi.service.StudentService;
import com.pingbu.tijian.hospital.backapi.service.UserInfoService;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/student")
public class StudentController {

    private static Logger logger = LoggerFactory.getLogger(StudentController.class);

    @Autowired
    private UserInfoService userService;
    @Autowired
    private StudentService studentService;

    /**
     *
     * @return
     */
    @PostMapping(value = "/page")
    public ResultBean<PageInfo<Student>> page(@RequestBody Student param ) {
        ResultBean<PageInfo<Student>> rb1 = studentService.page(param);
        return rb1;
    }

//    @PostMapping(value = "/add")
//    public ResultBean<Integer> add(@RequestBody Student param) {
//        ResultBean<Integer> rb = studentService.add(param);
//        return rb;
//    }

    @PostMapping(value = "/delete")
    public ResultBean<Integer> delete(@RequestBody Student param) {
        ResultBean<Integer> rb = studentService.delete(param);
        return rb;
    }

    @PostMapping(value = "/save")
    public ResultBean<Integer> update(@RequestBody Student param) {
        if (param.getNoid() == null) {
            ResultBean<Integer> rb2 = studentService.add(param);
            return rb2;
        }
        ResultBean<Integer> rb = studentService.update(param);
        return rb;
    }

    @PostMapping(value = "/list")
    public ResultBean<List<Student>> list(Student param) {
        ResultBean<List<Student>> rs1 = studentService.list(param);
        return rs1;
    }


}
